Page 95 - 2629_Devagiri_C-7
P. 95
Program 7 To print “Eligible to vote” if the age is greater than or equal to 18, else “Not eligible to vote”
Program7.py
File Edit Format Run Options Window Help
age = int(input("Enter your age: "))
print("Eligible to vote" if age >= 18 else "Not eligible to vote")
Output
Enter your age: 15
Not eligible to vote
SOME MORE PROGRAMS
Program 8 To Find the Largest of three numbers
Program8.py
File Edit Format Run Options Window Help
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
if a > b and a > c:
print("First number is the largest.")
elif b > c:
print("Second number is the largest.")
else:
print("Third number is the largest.")
Output
Enter first number: 15
Enter second number: 65
Enter third number: 45
Second number is largest.
93
Flow of Control in Python

